package com.anrongtec.zcpt.ui.activity.myfocus;

import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.anrongtec.zcpt.R;
import com.anrongtec.zcpt.base.BaseActivity;
import com.anrongtec.zcpt.model.focus.FocusPeopleInfo;
import com.anrongtec.zcpt.widget.ScrollListView;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class FocusPeopleDetailInfoActivity extends BaseActivity {

    @BindView(R.id.iv_add_photo)
    ImageView mIvAddPhoto;
    @BindView(R.id.lv_focus_people_detail)
    ScrollListView mLvFocusPeopleDetail;

    private FocusPeopleInfo mPeopleInfo;
    private List<String> infoList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_focus_people_detail_info);
        ButterKnife.bind(this);
        initViews();
    }

    @Override
    protected void initViews() {
        super.initViews();
        infoList = new ArrayList<>();
        mPeopleInfo = (FocusPeopleInfo) getIntent().getSerializableExtra("positionData");
        switch (mPeopleInfo.getName()) {
            case "张三":
                mIvAddPhoto.setImageResource(R.drawable.people1);
                break;
            case "张婷":
                mIvAddPhoto.setImageResource(R.drawable.people2);
                break;
            case "王国华":
                mIvAddPhoto.setImageResource(R.drawable.people3);
                break;
        }

        infoList.add("身份证号：" + mPeopleInfo.getIdNum());
        infoList.add("性别：" + mPeopleInfo.getSex());
        infoList.add("民族：" + mPeopleInfo.getNation());
        infoList.add("地址：" + mPeopleInfo.getLocation());
        infoList.add("类型：" + mPeopleInfo.getCrimeType());
        infoList.add("处置措施：" + "进行吸毒检测，呈阳性，移交所在县级进度主管部门处理，做好防复吸准备，及时放行，半月进行吸毒复检一次");
        infoList.add("布控单位：" + "市局情报中心");
        infoList.add("布控人：" + "石立飞");
        infoList.add("布控人电话：" + "15671604444");
        infoList.add("管控单位：" + "桥西");
        infoList.add("管控人：" + "王飞");
        infoList.add("管控人电话：" + "17708676121");

        Log.e("数量", infoList.size() + "");
        CommonAdapter<String> adapter = new CommonAdapter<String>(this,
                R.layout.item_focus_people_detail_info, infoList) {

            @Override
            protected void convert(ViewHolder viewHolder, String item, int position) {
                if (item.contains("类型")) {
                    SpannableString spanString = new SpannableString(item);
                    StyleSpan span = new StyleSpan(Typeface.BOLD_ITALIC);
                    spanString.setSpan(span, 3, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    viewHolder.setText(R.id.tv_focus_people_detail_info,
                            spanString.toString());
                } else {
                    viewHolder.setText(R.id.tv_focus_people_detail_info, item);
                }
            }
        };
        RelativeLayout inflate = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.header_lv_foxus_people_info, null);
        TextView name = (TextView) inflate.findViewById(R.id.tv_focus_people_detail_name);
        name.setText("姓名：" + mPeopleInfo.getName());
        TextView time = (TextView) inflate.findViewById(R.id.tv_focus_people_detail_time);
        time.setText(mPeopleInfo.getOnTime());
        mLvFocusPeopleDetail.addHeaderView(inflate);
        mLvFocusPeopleDetail.setAdapter(adapter);
    }
}
